import { convertMenuDataToTree } from '@/utils/common/tree';
import { fetchMenuList } from './menu';
/**
 * @description: 生成树选择器数据
 * @param {*} hasRoot 是否有根目录
 */
export const getParentMenus = async (hasRoot = true) => {
  const { data } = await fetchMenuList();
  if (hasRoot) {
    return [
      {
        menuId: 0,
        menuName: '桌面',
        path: '',
        children: convertMenuDataToTree(data.data || []),
      },
    ];
  } else {
    return convertMenuDataToTree(data.data || []);
  }
};
